import collections
class Solution(object):
    def fourSumCount(self, nums1, nums2, nums3, nums4):
        """
        :type nums1: List[int]
        :type nums2: List[int]
        :type nums3: List[int]
        :type nums4: List[int]
        :rtype: int
        """
        d = collections.defaultdict(int)
        n = len(nums1)
        total = 0
        for i in range(n):
            for j in range(n):
                d[nums1[i] + nums2[j]] += 1
        for i in range(n):
            for j in range(n):
                value = - nums3[i] - nums4[j]
                if value in d:
                    total += d[value]
        return total

